import 'package:flutter/material.dart';

import 'package:shop/util/http.dart';
import 'package:shop/models/swiper_data.dart';
import 'package:shop/models/catitem_data.dart';
import 'package:shop/models/home_data.dart';

class HomeViewModel extends ChangeNotifier {
  List<BannerInfo> bannerList = [];
  List<CatitemInfo> catitemsList = [];
  List<ProductData> floorList = [];

  void getHomeData() async {
    final swiperdata = await Http.request('/home/swiperdata');
    final catitemsdata = await Http.request('/home/catitems');

    bannerList = Swiperdata.fromJson(swiperdata).message ?? [];
    catitemsList = Catitemdata.fromJson(catitemsdata).message ?? [];

    notifyListeners();
  }

  void getListData(bool isPullUp) async {
    final floordata = await Http.request('/home/floordata');

    floorList = Floordata.fromJson(floordata).message ?? [];

    notifyListeners();
  }
}
